class Contact:
  def __init__(self, contacts):
    self.contacts = contacts
  
  def add(self, name, phone):
    if len(phone) > 11:
      raise ValueError("电话号码应该等于11位。")
    if name in self.contacts:
      raise ValueError("通讯录中已经存在此记录，请修改原记录。")
    self.contacts[name] = phone

  def modify(self, name, phone):
    if len(phone) > 11:
      raise ValueError("电话号码应该等于11位。")
    if name not in self.contacts:
      raise ValueError("该记录不存在，请添加。")
    self.contacts[name] = phone

  def delete(self, name):
    del self.contacts[name]

  def search(self, name):
    return self.contacts[name]

  def getAll(self):
    for kv in self.contacts.items():
      print(kv)

  def getContacts(self):
    return self.contacts

  def setContacts(self, contacts):
    self.contacts = contacts